package com.chenl.provider.DEMOS.设计模式;


import com.chenl.provider.DEMOS.设计模式.策略模式.one.AnimalContext;
import com.chenl.provider.DEMOS.设计模式.策略模式.one.PersonForAnimal;
import com.chenl.provider.DEMOS.设计模式.策略模式.two.AnimalContextTwo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/Animal")
public class demoController {
    @Autowired
    AnimalContext animalContext;
    @Autowired
    AnimalContextTwo animalContextTwo;

    @Autowired
    PersonForAnimal person;

    @PostMapping("/test")
    public void test(){
        //1.使用applicationContext根据名称直接进行Bean的获取(使用枚举封装)
        Integer data=1;
        Integer data2=3;
        String a = animalContext.doEat(data, "猪皮");
        String b = animalContext.doEat(data2, "恶霸");
        System.out.println("结束了:"+a);
        System.out.println("结束了:"+b);

        //2.使用jdk8 函数式接口,解决爆炸类问题(但也不一定就更好)
        String c = animalContextTwo.AnimalEat(1, "死猪");
        String d = animalContextTwo.AnimalEat(3, "汉堡");
        System.out.println("结束咯:"+c);
        System.out.println("结束咯:"+d);
        log.info("啦啦啦");
        new Thread(()->{
            log.info("哈哈哈");
        }).start();

    }
}
